﻿USE [kb.net]
GO

/****** Object:  Trigger [dbo].[Activated_Archived]    Script Date: 7/9/2012 6:16:55 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		R. Brian Amesbury
-- Create date: 9 July 2012
-- Description:	Archives an Account
-- =============================================
CREATE TRIGGER [dbo].[Activated_Archived] 
   ON  [dbo].[Account_Activated]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
	INSERT INTO [dbo].[Account_Activated_History]
		(
			ID,
			DateActivated,
			DateDeactivated
		)
		VALUES
		(
			(SELECT ID FROM deleted),
			(SELECT DateActivated FROM deleted),
			CURRENT_TIMESTAMP
		)
END

GO

